<?php

declare(ENCODING = 'UTF-8');

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *	
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */	

/**
 * @package auxo
 * @subpackage Tests
 * @version $Id$
 */

/**	
 * The Component Parameter Test 
 *	
 * @package auxo
 * @subpackage tests
 * @version $Id$	
 * @copyright Copyright belongs to the respective authors
 * @author AHN
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
class  tx_auxo_ComponentParameter_testcase extends PHPUnit_Framework_testcase  {
	/**
	 * Sets up a test enviroment of this testcase.
	 */
	public function setUp() {
	}
	
	/**
	 * Testcase: Create a string parameter and get values
	 * 
	 * @return void
	 */
	public function testCreateStringAndGetComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter(tx_auxo_ComponentConfigurationParameter::TYPE_STRING, 'abcdef');
		$this->assertEquals('abcdef', $parameter->getData());
	}

	/**
	 * Testcase: Create a integer parameter and get values
	 * 
	 * @return void
	 */
	public function testCreateIntegerAndGetComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter(tx_auxo_ComponentConfigurationParameter::TYPE_INTEGER, 123456);
		$this->assertEquals(123456, $parameter->getData());
	}

	/**
	 * Testcase: Create a floating point parameter and get values
	 * 
	 * @return void
	 */
	public function testCreateFloatAndGetComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter(tx_auxo_ComponentConfigurationParameter::TYPE_FLOAT, 12.34);
		$this->assertEquals(12.34, $parameter->getData());
	}	
		
	/**
	 * Testcase: Create a boolean parameter and get values
	 * 
	 * @return void
	 */
	public function testCreateBooleanAndGetComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter(tx_auxo_ComponentConfigurationParameter::TYPE_BOOLEAN, true);
		$this->assertTrue($parameter->getData());
	}	

	/**
	 * Testcase: Set and get name of a parameter
	 * 
	 * @return void
	 */	
	public function testSetGetNameOfComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter();
		$parameter->setName('foo');
		$this->assertEquals('foo', $parameter->getName());
	}

	/**
	 * Testcase: Set and get type of a parameter
	 * 
	 * @return void
	 */	
	public function testSetGetTypeOfComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter();
		$parameter->setType(tx_auxo_ComponentConfigurationParameter::TYPE_INTEGER);
		$this->assertEquals(tx_auxo_ComponentConfigurationParameter::TYPE_INTEGER, $parameter->getType());
	}	

	/**
	 * Testcase: Set data and get mapped a integer parameter
	 * 
	 * @return void
	 */	
	public function testSetAndGetMappedIntegerComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter();
		$parameter->mapValueToData('123456');
		$this->assertEquals(tx_auxo_ComponentConfigurationParameter::TYPE_INTEGER, $parameter->getType());
		$this->assertTrue(is_int($parameter->getData()));
	}	

	/**
	 * Testcase: Set data and get mapped a float parameter
	 * 
	 * @return void
	 */	
	public function testSetAndGetMappedFloatComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter();
		$parameter->mapValueToData('12.46');
		$this->assertEquals(tx_auxo_ComponentConfigurationParameter::TYPE_FLOAT, $parameter->getType());
		$this->assertTrue(is_float($parameter->getData()));
	}
		
	/**
	 * Testcase: Set data and get mapped a string parameter
	 * 
	 * @return void
	 */	
	public function testSetAndGetMappedStringComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter();
		$parameter->mapValueToData('foo');
		$this->assertEquals(tx_auxo_ComponentConfigurationParameter::TYPE_STRING, $parameter->getType());
		$this->assertTrue(is_string($parameter->getData()));
	}	
	
	/**
	 * Testcase: Set data and get mapped a boolean parameter
	 * 
	 * @return void
	 */	
	public function testSetAndGetMappedBooleanComponentParameter() {
		$parameter = new tx_auxo_ComponentConfigurationParameter();
		$parameter->mapValueToData('true');
		$this->assertEquals(tx_auxo_ComponentConfigurationParameter::TYPE_BOOLEAN, $parameter->getType());
		$this->assertTrue(is_bool($parameter->getData()));
	}	
		
	/**
	 * Tears down a created test enviroment of this testcase.
	 */
	public function tearDown() {
	}
}